package com.example.demo.service;

import com.example.demo.mapper.UserMapper;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    @Tool(description = "根据用户id获取用户的名字")
    public String getName(@ToolParam(description = "用户id") Integer userId) {
        return userMapper.selectById(userId).getName();
    }

    @Tool(description = "根据用户id获取用户的年龄")
    public Integer getAge(@ToolParam(description = "用户id") Integer userId) {
        return userMapper.selectById(userId).getAge();
    }

    @Tool(description = "根据用户名获取用户年龄")
    public Integer getAgeByName(@ToolParam(description = "用户名") String name) {
        return userMapper.selectByName(name).getAge();
    }
}
